package leetcode;

import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

/**
 * 描述:155. 最小栈
 *
 * @author Madison You
 * @created 22:54
 */
public class Easy_155_MinStack {

}

class MinStack {

    Deque<Integer> list = null;
    Deque<Integer> sortList = null;

    public MinStack() {
        list = new LinkedList<>();
        sortList = new LinkedList<>();
        sortList.push(Integer.MAX_VALUE);
    }

    public void push(int val) {
        list.push(val);
        sortList.push(Math.min(sortList.peek(), val));
    }

    public void pop() {
        list.pop();
        sortList.pop();
    }

    public int top() {
        return list.peek();
    }

    public int getMin() {
        return sortList.peek();
    }
}